<?php
namespace app\personal\controller;
use think\Controller;
use think\Db;
use think\Session;
use think\Request;

class Answer extends Controller
{
    public function index()
    {
        if(empty(Session::get('id'))){
            $this->error('请先登录账号...','./login/index');
        } else {

        $id = Session::get('id');
        $list = Db::table('user_info')->where('uid',$id)->find();

        //查询回复信息
        $content = Db::table('answer_note')->where('uid',$id)->select();

        // Db::table('think_user')->alias(['think_user'=>'user','think_dept'=>'dept'])->join('thin
        //     k_dept','dept.user_id= user.id')->select();

        $data = Db::table('note')->alias('n')->join('answer_note w','n.id = w.nid')->where('w.uid',$id)->select();

        foreach ($data as $val){
            $w = Db::table('answer_note')->where('nid',$val['nid'])->select();
        var_dump($w);
        }
        // //连接数据库
        // $link = mysqli_connect('localhost','root','');
        // //选择数据库
        // mysqli_select_db($link,'lol_bbs');
        // //设置字符集
        // mysqli_set_charset($link,'utf8');

        // // 根据回复关联贴子id 查询帖子信息
        // // $sql = "select n.*,w.* from note n, answer_note w where  n.id= w.nid and w.uid = $id";
        // $sql = "select * from answer_note where uid=9";
        // //执行sql
        // $result = mysqli_query($link,$sql);
        // var_dump($result);
        

        //处理结果集
        // $data = mysqli_fetch_assoc($result);
        // var_dump($data);
        $this->assign('list',$list);
        $this->assign('content',$content);
        $this->assign('data',$data);
        $this->assign('w',$w);
        var_dump($data);
        var_dump($content);
        // var_dump($tiezi);
        return $this->fetch('index/answer');
        }
    }

    public function get()
    {
        date_default_timezone_set('PRC');
        $

        $a = 1+1;
        return $b = '111111111111';
    }
}


